package com.jari.lg.service.profile.parking;

import com.jari.lg.domain.ParkingCarTypeCostHisEntity;
import com.jari.lg.domain.ParkingLotBase;
import com.jari.lg.mapper.ParkingCarTypeCostHisEntityMapper;
import com.jari.lg.mapper.ParkingLotBaseMapper;
import com.jari.lg.utils.BaseData;
import com.jari.lg.utils.Constants;
import com.jari.lg.utils.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ParkingCarTypeCostHisService {

    @Autowired
    private ParkingCarTypeCostHisEntityMapper parkingCarTypeCostHisEntityMapper;

    @Autowired
    private ParkingLotBaseMapper parkingLotBaseMapper;

    /*
    *   每天
    * */
    public void makeInfo(){
        ParkingCarTypeCostHisEntity entity;
        List<ParkingLotBase> parkingLotBaseList = BaseData.parkingLotBaseList;
        for(ParkingLotBase parkingLotBase : parkingLotBaseList){
            entity = generate(parkingLotBase);
            parkingCarTypeCostHisEntityMapper.insert(entity);
        }

    }

    private ParkingCarTypeCostHisEntity generate(ParkingLotBase parkingLotBase){
        ParkingCarTypeCostHisEntity entity = new ParkingCarTypeCostHisEntity();
        entity.setCost(Utils.makeLong(10000));
        entity.setDatastatus(Constants.DATA_STATUS_ONE);
        entity.setDatetime(new Date());
        entity.setGmtcreate(new Date());
        entity.setParkingid(Long.parseLong(parkingLotBase.getParkingid()));
        entity.setParkingname(parkingLotBase.getParkingname());
        entity.setParktype(parkingLotBase.getParkingtype());
        return entity;
    }
}
